package com.wk.springboot.taskletStep;

import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.stereotype.Component;

/**
 * @Classname MyTaskletStep
 * @Description 自定义一个taskletStep
 * @Date 2020/3/31 14:37
 * @Author by weikai
 */
@Component
public class MyTaskletStep implements Tasklet {

  /**
   * 这里可以通过修改ExitStatus状态来影响step的状态
   * @param contribution
   * @param chunkContext
   * @return
   */
  @Override
  public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) {

    System.out.println("这是一个taskletStep");
    contribution.setExitStatus(ExitStatus.COMPLETED);
    System.out.println("这个失败哦");
    return RepeatStatus.FINISHED;
  }
}
